package com.hjx.movie.core.player.service;


import com.hjx.movie.core.player.entity.Folder;
import com.hjx.movie.core.player.util.PlayUtil;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2021/5/4 - 17:00
 */
@Service
@CacheConfig(cacheNames = "Demo:SpringCache:FolderCache",keyGenerator = "cacheKeyGenerator")
public class PlayService {

    @Cacheable(unless="#result == null")
    public List<Folder> initFolderList(){
        return PlayUtil.initFileList();
    }

    @CacheEvict(value = "Demo:SpringCache:FolderCache",allEntries=true,beforeInvocation = true)
    public boolean deleteCache() {
        return true;
    }

}
